﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FilStartUps.DAL;

namespace FilStartUps
{
    public partial class activation : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["e"].Trim() != null && Request.QueryString["q"].Trim() != null)
            {
                //Validate User
                using (FilStartUpsEntities db_connect = new FilStartUpsEntities())
                {
                    var verify = (from m in db_connect.Members
                                  where m.emailaddress.Equals(Request.QueryString["e"].Trim())
                                  && m.validationcode.Equals(Request.QueryString["q"].Trim())
                                  select m).SingleOrDefault();
                   //Check If the Activation Key and Email is Correct
                    if (verify != null)
                    {
                        //Redirect To Activation Page.
                        //or
                        //lttext ="Profile and Forum" Thread.Sleep(2000); ==> Redirect
                        Response.Redirect("activation.aspx");
                    }
                    else
                    {
                        //Redirect To Registration Page
                        Response.Redirect("../Account/Registration.aspx");
                    }
                }
            }
        }
    }
}